package com.example.leonard.core.mq.mqconfig;

import org.springframework.amqp.core.Binding;
import org.springframework.amqp.core.BindingBuilder;
import org.springframework.amqp.core.DirectExchange;
import org.springframework.amqp.core.Queue;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
public class DirectConfig {
    @Bean
    public Queue directQueue() {
        return new Queue(MQConstants.DIRECTQUEUE);
    }

    @Bean
    public Queue directQueues() {
        return new Queue(MQConstants.DIRECTQUEUES);
    }

    @Bean
    public DirectExchange directExchange() {
        return new DirectExchange(MQConstants.DIRECTEXCHANGE);
    }

    @Bean
    public Binding binding() {
        return BindingBuilder.bind(directQueue()).to(directExchange()).with(MQConstants.DIRECT_ROUTING_KEY);
    }

    @Bean
    public Binding bindings() {
        return BindingBuilder.bind(directQueues()).to(directExchange()).with(MQConstants.DIRECT_ROUTING_KEYS);
    }
}
